package com.kitty.game.skill.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SkillBox {

    private Map<Integer, RoleSkill> skills = new HashMap<>();

    public Map<Integer, RoleSkill> getSkills() {
        return skills;
    }

    public void setSkills(Map<Integer, RoleSkill> skills) {
        this.skills = skills;
    }

    public void learnSkill(RoleSkill roleSkill) {
        this.skills.put(roleSkill.getSkillId(), roleSkill);
    }

    public RoleSkill querySkillBy(int skillId) {
        return skills.get(skillId);
    }

    public List<RoleSkill> queryAllSkills() {
        return new ArrayList<>(skills.values());
    }

    /**
     * 返回所有辅助技能
     * @return
     */
    public List<RoleSkill> getAllAssistSkills() {
        List<RoleSkill> result = new ArrayList<>();
        for (Map.Entry<Integer, RoleSkill> entry : getSkills().entrySet()) {
            RoleSkill skill = entry.getValue();
            if (skill.isAssistSkill()) {
                result.add(skill);
            }
        }
        return result;
    }

}
